--Reward system para misiones
local Player = GAMESTATE:GetMasterPlayerNumber()
local CurStats = STATSMAN:GetCurStageStats():GetPlayerStageStats(Player)
local HitHoldTicks = CurStats:GetTapNoteScores('TapNoteScore_CheckpointHit')
local TnsW1s = CurStats:GetTapNoteScores('TapNoteScore_W1')
local TnsW2s = CurStats:GetTapNoteScores('TapNoteScore_W2')
local MissHoldTicks = CurStats:GetTapNoteScores('TapNoteScore_CheckpointMiss')
local TnsMiss = CurStats:GetTapNoteScores('TapNoteScore_Miss')
local Grade = CurStats:GetGrade()

--Condicionales...
local Perfect = HitHoldTicks + TnsW1s + TnsW2s
local Great = CurStats:GetTapNoteScores('TapNoteScore_W3')
local Good = CurStats:GetTapNoteScores('TapNoteScore_W4')
local Bad = CurStats:GetTapNoteScores('TapNoteScore_W5')
local Miss = MissHoldTicks + TnsMiss

local MaxCombo = CurStats:MaxCombo()
local Score = CurStats:GetScore()
local Life = CurStats:GetCurrentLife()
local Mines = CurStats:GetTapNoteScores('TapNoteScore_HitMine')

local S = Grade == 'Grade_Tier01' or Grade == 'Grade_Tier02'
local A = Grade == 'Grade_Tier03'
local B = Grade == 'Grade_Tier04'
local C = Grade == 'Grade_Tier05'
local D = Grade == 'Grade_Tier06'
local F	= Grade == 'Grade_Tier07' or Grade == 'Grade_Failed'

local FullCombo = function() return CurStats:FullCombo() end

--La Misión que acabas de jugar
local PlayedMission = getenv("PlayedMission")
--SCREENMAN:SystemMessage(PlayedMission.MissionName.."\n"..PlayedMission.Description)

--[[----------------------------------------------------
CONTROL DE UNLOCKS
--]]----------------------------------------------------

local MissionUnlocks = {
	["Initial"] = {
		Cond = S or A,
		Reward = "Start",
	};
	--Se necesita un default. NO MODIFICAR!
	["DEFAULT"] = { Cond = false };
}

--[[----------------------------------------------------
FIN DEL CONTROL DE UNLOCKS
--]]----------------------------------------------------

--verificar primero si la mision que se ha jugado existe en las entradas...
local ThisMission = MissionUnlocks[ PlayedMission.MissionName ]
if not ThisMission then
	ThisMission = MissionUnlocks["DEFAULT"]
end

--aver si pasaste xD
local bPassed = ThisMission.Cond
if bPassed then
	local ToUnlock = ThisMission.Reward
	SCREENMAN:SystemMessage("Unlocked entry: "..ToUnlock)
	UNLOCKMAN:UnlockEntryID( ToUnlock )
end

--se necesita regresar algún tipo de actor...
return Def.Actor{}